import java.util.concurrent.locks.ReentrantReadWriteLock;

public class Test19 {
    static class Tmp{
        int tmp = 0;
        public void add(){
            tmp++;
            System.out.println();
        }
    }
    public static void main(String[] args) throws InterruptedException {
        Tmp tmp = new Tmp();
        Thread thread1 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    tmp.add();
                }
            }
        });
        Thread thread2 = new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    tmp.add();
                }
            }
        });
        thread1.start();
        thread2.start();
        thread1.join();
        thread2.join();
        System.out.println(tmp.tmp);

    }
}
